<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .root{
            width: 200px;
            height: 200px;
            background-color: black;
        }

        .box{
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div class="root" id="root">
        <div class="root" id="box"></div>
    </div>
    
    <script>
         
         var root=document.getElementById("root");
         var box=document.getElementById("box");
        root.onclick=function(){
            console.log("root");
        }

        box.onclick=function(e){
            console.log("box");
        }
    </script>
</body>
</html>